package com.wang.service.impl;

import com.aaa.entity.TbArticle;
import com.aaa.vo.GoodsNumVo;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wang.mapper.PageContextMapper;
import com.wang.service.PageContextService;
import com.wang.vo.AllVo;
import com.wang.vo.GoodsVo;
import com.wang.vo.PageContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author :  DongZheng Wang
 * @PROJECT_NAME: fifth-cai-parent
 * @date :  2023-03-03 09:11
 **/
@Service
public class PageContextImpl extends ServiceImpl<PageContextMapper, PageContext> implements PageContextService {
    @Autowired
    private PageContextMapper mapper;

    @Override
    public Result listPage() {
        List<PageContext> pages = mapper.pages();
        return new Result(2000,"sucess",pages);
    }

    @Override
    public Result All() {
        List<AllVo> all = mapper.All();
        return new Result(2000,"sucess",all);
    }

    @Override
    public Result findGoodsByBid(String bid) {
        List<GoodsVo> goodsAndNumByBid = mapper.findGoodsByBid(bid);
        return new Result(2000,"查询成功",goodsAndNumByBid);

    }

    @Override
    public Result AllArtice(String id) {
        List<TbArticle> tbArticles = mapper.AllArtice(id);
        if(tbArticles!=null) {
            return new Result<>(2000, "查询成功", tbArticles);
        }
          return new Result<>(5001,"查询失败");
    }
}
